package com.atguigu.spzx.product.controller;

import com.atguigu.spzx.model.pojo.product.ProductSku;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.h5.IndexVo;
import com.atguigu.spzx.product.service.CategoryService;
import com.atguigu.spzx.product.service.ProductService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/product")
@Tag(name = "前台界面管理")
//@CrossOrigin
public class IndexController {
    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ProductService productService;

    @GetMapping("/index")
    @Operation(summary = "获取首页数据")
    public Result<IndexVo> getIndex(){
        IndexVo indexVo = new IndexVo();
        indexVo.setCategoryList(categoryService.getFirstCategory());
        indexVo.setProductSkuList(productService.getProductSkuBySale());
        return Result.ok(indexVo);
    }


}
